<script setup lang="ts">
import { ref } from 'vue'

const count = ref(0)
const T: any = ref(0)
const pauseBtnDisabled = ref(false)

// 开始滚动
function start() {
    if (T.value) return
    T.value = setInterval(() => {
        if (count.value >= 100) count.value = 0
        count.value++
    }, 1)
}
// 暂停滚动
function pause() {
    if (!T.value) return
    clearInterval(T.value)
    pauseBtnDisabled.value = true
    setTimeout(() => {
        T.value = 0
        pauseBtnDisabled.value = false
    }, 5000);
}
</script>


<template>
    <pre>
一等奖：1-5
二等奖：6-20
三等奖：21-100
    </pre>
    <div class="A">
        <div class="A_T"> {{ count }} </div>
        <div class="A_B">
            <button class="A_B_S" v-show="!T" @click="start">开始</button>
            <button class="A_B_P" v-show="T" :disabled="pauseBtnDisabled" @click="pause">暂停</button>
        </div>
    </div>
</template>


<style scoped>
pre {
    color: #ff0000;
    background-color: #f2f2f2;
    display: flex;
    align-content: center;
    justify-content: center;
    align-items: center;
    border-radius: 1rem;
    padding: 1rem;
    font-size: 2rem;
}
button {
    white-space: nowrap;
    padding: 0.7em 1.6em;
    color: #fff;
    background-color: #007BFF;
    border: none;
    border-radius: 0.5em;
    cursor: pointer;
    transition: background-color 0.3s ease;
}
button:hover {
    background-color: #a0a0a0;
}
button:active {
    background-color: #a0a0a0;
}
button[disabled] {
    background-color: #a0a0a0;
}

.A {
    display: flex;
    align-content: center;
    justify-content: center;
    align-items: center;
    flex-wrap: nowrap;
    flex-direction: column;
}
.A_T {
    font-size: 10rem;
}
.A_B button {
    font-size: 3rem;
}
.A_B_S {
    background-color: #14a52a;
}
.A_B_P {
    background-color: #cd1111;
}
</style>